<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

<script>
// Promise静态方法
// Promise.resolve()方法默认返回一个成功状态的promise对象

// Promise.resolve参数为非promsie对象时,返回的p1为成功状态,结果为传入的参数
let p1 = Promise.resolve('hello');
p1.then(
    (res)=>{
        console.log( 'p1成功',res );
    },
    (res)=>{
        console.log( 'p1失败',res );
    }
)

// 如果Promise.resolve参数为一个promise对象时,返回的p2跟随传入的promise对象的状态和结果
let p2 = Promise.resolve(new Promise((resolve,reject)=>{
    // resolve(123);
    reject(456);
}));
p2.then(
    (res)=>{
        console.log( 'p2成功',res );
    },
    (res)=>{
        console.log( 'p2失败',res );
    }
)


</script>
</body>
</html>